package edos.prm.artifact;

/**
 * An {@code AttributePair} is a mapping from a String property to either a
 * specific object value, or to the {@code don't-care} value.
 * 
 * {@code AttributePair} objects are used in the {@code lookup} operation of
 * the {@code ArtifactManager} activity.
 */
public final class AttributePair<E> {

	private String property;
	private E value;
	private boolean isDontCare;
	
	public AttributePair(String property, E value) {
		super();
		this.property = property;
		this.value = value;
		this.isDontCare = false;
	}
	
	/**
	 * Creates a property with the {@code don't-care} value.
	 * 
	 * @param property the String name of the property of the pair
	 */
	public AttributePair(String property) {
		this.property = property;
		this.value = null;
		this.isDontCare = true;
	}

	/**
	 * Return the name of the property of this attribute pair
	 * 
	 * @return the property String name
	 */
	public String getProperty() {
		return property;
	}

	/**
	 * Return the value of the attribute pair, if this value is not the
	 * {@code don't-care} value. The value null is returned if this is the
	 * {@code don't-care} value.
	 * 
	 * @return the value of the attribute pair.
	 */
	public E getValue() {
		return value;
	}
	
	/**
	 * Specifies if the value of this pair is the {@code don't-care} value.
	 * 
	 * @return true if the value is the {@code don't-care} value.
	 */
	public boolean hasDontCareValue() {
		return this.isDontCare;
	}
}
